<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="format-detection" content="telephone=no" />
    <meta name="format-detection" content="email=no" />
    <title>推荐</title>
    <link rel="stylesheet" href="../css/api.css">
    <link rel="stylesheet" href="../css/vant.css">
    <link rel="stylesheet" href="../css/main.css">
    <style>
        header {
            height: auto;
        }

        .my_tab_props {
            /* width: auto;
            margin-right: 15px;
            color: black; */
            border: 1px solid black;
        }

         .van-tab {
            flex: none;
        }

     .van-tabs__wrap--scrollable .van-tab {
        flex: 0 0 auto;
        border: 1px solid yellow;
        
            /* -webkit-box-flex: 1;
            -webkit-flex: 1 0 auto; */
            /* flex: none;
            padding: 0 ; */
        }
    </style>
</head>

<body>
    <div class="app">
        <van-tabs class="my_tab_head" v-model="active" color="#ffffff" title-inactive-color="#666666"
            title-active-color="#2A2A2A" @click="setFrameGroupIndex"  sticky>
            <van-tab v-for="item in categoryList" :title="item.val" >
            </van-tab>
        </van-tabs>
    </div>
    <!-- <script src="../script/api.js"></script> -->
    <script src="../script/flexible.js"></script>
    <!-- <script src="../script/fastclick.js"></script> -->
    <script src="../script/vue.min.js"></script>
    <script src="../script/iconfont.js"></script>
    <script src="../script/vant.min.js"></script>
    <!-- <script src="../script/swiper.min.js"></script> -->
    <script src="../script/common.js"></script>
    <!-- <script src="../script/businessCommon.js"></script> -->
    <!-- <script src="../script/restful.js"></script> -->
    <script>
            vm = new Vue({
                el: '.app',
                data: {
                    headerH: 0,
                    footerH: 0,
                    frames: [],
                    active: 0,
                    categoryList: [{
                        val: 'asfasd'
                    },{
                        val: 'hhhhhhh'
                    },{
                        val: 'kkkkkkk'
                    },{
                        val: 'aaaaaaaaa'
                    },{
                        val: 'eeee'
                    },{
                        val: 'bbbb'
                    },{
                        val: 'mmmm'
                    },{
                        val: 'ssss'
                    }],
                    selectActive: 0
                },
                mounted() {
                    var header = $api.dom('.my_tab_head');
                    this.headerH = $api.offset(header).h;
                    if (this.categoryList.length == 0) {
                        this.getCategoryList()
                    }
                },

                methods: {
                    //获取分类频道
                    getCategoryList() {
                        var vm = this
                        release("getListOptions")(10, function (ret, err) {
                            if (ret.data && ret.data.length > 0) {

                                vm.categoryList = ret.data
                                vm.categoryList.unshift({ val: "推荐", id: null })//增加全部分类

                                vm.frames = []
                                vm.categoryList.forEach(item => {
                                    var framItem = {
                                        name: 'circle_list_frm',
                                        url: './circle_list_frm.html',
                                        pageParam: {
                                            screenType: 0,
                                            channelId: item.id
                                        }
                                    }
                                    vm.frames.push(framItem)
                                });
                                vm.openFrameGroup();
                            }
                        });
                    },
                    openFrameGroup() {
                        var vm = this;
                        api.openFrameGroup({
                            name: 'circle_recommend_group',
                            rect: {
                                marginTop: vm.headerH + api.pageParam.headH,
                            },
                            scrollEnabled: true,
                            frames: vm.frames,
                            preload: 3,
                        }, function (ret, err) {
                            vm.active = ret.index;
                        });
                    },
                    setFrameGroupIndex() {
                        api.setFrameGroupIndex({
                            name: 'circle_recommend_group',
                            scroll: true,
                            index: this.active,
                            reload: true
                        });
                    },
                },
            })
    </script>
</body>

</html>